using System;
using System.Collections.Generic;
using System.Text;

using System.Net;
using System.Net.Sockets;

namespace Parsifal
{
    public class ManageAsyncSendingData
    {
        private byte[] bData;

        const int bufferDataReader = daxClass.dxTCPServer.bufferDataReader;

        private Utility iUtility;

        public ManageAsyncSendingData(Utility aUtility)
        {
            iUtility = aUtility;
        }


        public void SendData(Socket aClient, string data)
        {

            try
            {
                bData = new byte[bufferDataReader];
                bData = iUtility.ConvertStringToBye(data);

                aClient.BeginSend(bData, 0, bData.Length, SocketFlags.None, new AsyncCallback(OnSendedData), aClient);

            }
            catch (Exception err)
            {

                throw err;
            }



        }

        private void OnSendedData(IAsyncResult iar)
        {
            try
            {
                Socket remote = (Socket)iar.AsyncState;
                int sent = remote.EndSend(iar);

            }
            catch (Exception err)
            {
                throw new Exception();
            }
        }
    }
}
